package cn.itsource.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//标志这个类是一个配置类
public class MyWebMvcConfiguer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//拦截所有
                //下面是需要放行的
                .excludePathPatterns("/login/**")//登录
                .excludePathPatterns("/user/register/**")//用户注册
                .excludePathPatterns("/shop/settlement")//店铺入驻
                .excludePathPatterns("/fastDfs/**")//图片上传
                .excludePathPatterns("/front/**")//前台用户访问的接口
                .excludePathPatterns("/verifyCode/**");//获取验证码
    }
}
